	$(function(){
		$("#determineReceiptBtn").on("click", function () {
			var orderId = getUrlParameter("orderId");
			j.ajaxWithOutJson("POST", "determineReceipt", {orderId: orderId}, null, null, function (data) {
				if(data == "success"){
					window.location.reload();
				}else {
					console.log("determine error")
				}
			})
		});

		$("button:contains('评论')").on("click",function(){
			$("#modal_body").empty();
			$("#myConfirm").children().eq(1).remove();
			$("#myConfirm").append($('<button type="button" class="btn btn-primary" id="confirmComment">确定</button>'));
			var id = $(this).attr("id");
			$("#myModal").modal('show');
			$("#myModalLabel").text("请对本次订单进行评论，多谢");
			$("#modal_body").append($('<input type="text" maxlength="50" placeholder="请对本订单进行评论"/><br/>'));
			
			//添加星星
			$("#modal_body").append($("#star").clone(true).removeAttr("style"));
			
			$("button[id='confirmComment']").on("click", function(){
				$("button:contains('评论')").remove();
				var starCount = $(".comment").attr("id");
				var comment = $("#modal_body").children().eq(0).val();
				$("#myModal").modal('hide');
				j.ajax("POST","comment?o_id=" + id + "&comment=" + comment + "&starCount=" + starCount, null, null, this, function(m){
					$("#myModal").modal('hide');
				});
			});
			
		});
		$("button:contains('投诉')").on("click",function(){
			$("#modal_body").empty();
			$("#myConfirm").children().eq(1).remove();
			$("#myConfirm").append($('<button type="button" class="btn btn-primary" id="confirmComplain">确定</button>'));
			var id = $(this).attr("id");
			$("#myModal").modal('show');
			$("#myModalLabel").text("确认投诉吗");
			$("#modal_body").append($('<input type="text" placeholder="填写投诉理由"/>'));
			
			$("button[id='confirmComplain']").on("click", function(){
				$("button:contains('投诉')").remove();
				var comment = $("#modal_body").children().eq(0).val();
				$("#myModal").modal('hide');
				j.ajax("POST","complain?o_id=" + id + "&complain=" + comment, null, null, this, function(m){
					$("#myModal").modal('hide');
				});
			});
		});
	});